using System;
using System.Collections.Generic;
using System.Text;
using Ionic.Zip;
using System.IO;
namespace System {
	public class ZCache:Cache {
		public ZCache(string s) : base(s) { }
		public override string Get(string source,int timeoutMinutes) {
			string ret="";
			string hash=CalculateMD5Hash(source);
			using(ZipFile zip=new ZipFile(this.key))
			{
				if(zip.ContainsEntry(hash)&&zip[hash].LastModified>DateTime.Now.AddMinutes(-timeoutMinutes))
					ret=new StreamReader(zip[hash].OpenReader()).ReadToEnd();
				else
				{
					ret=this.wc.DownloadString(source);
					zip.UpdateEntry(hash,ret);
					zip.Save();
				}
			}
			return ret;
		}
	}
}
